package com.inspire.myapp;

import java.util.Enumeration;

import com.codename1.ui.ComboBox;
import com.codename1.ui.Container;
import com.codename1.ui.events.SelectionListener;
import com.codename1.ui.layouts.Layout;
import com.codename1.ui.list.ContainerList;
import com.codename1.ui.table.TableLayout;
import com.codename1.ui.table.TableLayout.Constraint;

public class menutab_list_peripherique extends Container {

	public menutab_list_peripherique(tag tagitem) {
		TableLayout tabP2l=new TableLayout(1,2);
		this.setLayout(tabP2l);
		
		/*final Container tab2=new Container();
		TableLayout tab2l=new TableLayout(objets.obj.peripheriques.size(),1);
		tab2.setScrollableY(true);*/
	
		final ContainerList listItem=new ContainerList();
		listItem.setUIID("Container");
		final ContainerList listItem2=new ContainerList();
		listItem2.setUIID("Container");
		
		Enumeration keys=objets.obj.peripheriques.keys();
		while (keys.hasMoreElements()) {
			String id = (String) keys.nextElement();
			final peripherique p=(peripherique) objets.obj.peripheriques.get(id);
			peripherique_item pp=new peripherique_item(p);
			for (tag tagp : p.tags) {
				if (tagp.uuid.equals(tagitem.uuid)){
					if (!p.ecriture_type.equals("SANS")) {
						listItem2.addComponent(pp);
					} else {
						listItem.addComponent(pp);
					}
					
				}
			}

        	
		}
		listItem.repaint();
		listItem2.repaint();
		
		if (listItem.getComponentCount()>0){
			this.addComponent(listItem);
		}
		if (listItem2.getComponentCount()>0){
			this.addComponent(listItem2);
		}
		if (listItem.getComponentCount()>0 && listItem2.getComponentCount()>0){
			TableLayout.Constraint c=(Constraint) tabP2l.getComponentConstraint(listItem);
			c.setWidthPercentage(50);
			TableLayout.Constraint c2=(Constraint) tabP2l.getComponentConstraint(listItem2);
			c2.setWidthPercentage(50);			
		}

	}

	public menutab_list_peripherique(Layout layout) {
		super(layout);
		// TODO Auto-generated constructor stub
	}

}
